<?php
declare (strict_types = 1);

namespace app\admin\controller;

use think\facade\Db;
use think\facade\Request;
use think\facade\View;

class Order
{
    public function orderDetail(){
        return view();
    }
    public function orderList(){
        //表单数据接收
        $statu=input('post.statu');
        $d1=input('post.date1');
        $d2=input('post.date2')==""?time():input('post.date2');
        $m1=input('post.money1')==""?0:input('post.money1');
        $m2=input('post.money2')==""?999999999:input('post.money2');
        $sn=input('post.sn');
        $post=Request::param();

        //where条件拼接
        $where=[];
        if(isset($statu) && $statu<>""){$where[]=['ecm_order.status','in',$statu];}//订单状态查询
        if((isset($d1) && $d1<>'')||(isset($d2) && $d2<>'')){$where[]=['ecm_order.addtime','between time',$d1.','.$d2];}//订单时间范围查询
        if((isset($m1) && $m1<>'')||(isset($m2) && $m2<>'')){$where[]=['ecm_order.amount','between',$m1.','.$m2];}//订单金额范围查询
        if(isset($sn) && $sn<>""){$where[]=['ecm_order.order_sn','like','%'.$sn.'%'];}//订单编号模糊查询

        //订单查询
        $orderL=\app\admin\model\Order::getOrderList($where,$post);


        View::assign('statu',$statu);
        View::assign('sn',$sn);
        View::assign('m1',$m1);
        View::assign('m2',$m2);
        View::assign('order',$orderL);
        View::assign($post);

        //订单菜单状态查询
        $orderS=\app\admin\model\OrderStatus::getOrderStatus();
        View::assign('orderS',$orderS);
        return view();
    }
}
